package _11_整理题目._8_多线程._创建线程;

/**
 * 方法一：
 *      创建一个类，继承 Thread ，重写 run 方法
 *      new 一个类，并 start()
 *
 * 创建的类是一个外部类
 */
class Thread1 extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 4; i++) {
            try {
                Thread.sleep(3);
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println(getName() + " : " + i);
        }
    }
}

class Thread2 extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 4; i++) {
            try {
                Thread.sleep(3);
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println(getName() + " : " + i);
        }
    }
}

public class _01_继承_Thread_1_外部类 {

    public static void main(String[] args) {
        new Thread1().start();

        Thread th = new Thread2();
        th.start();
    }

}
